<template>
  <div class="app-container">
    <div class="container_p">
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="客戶姓名" prop="customerName">
          <el-input v-model="form.customerName" placeholder="請輸入客戶姓名" />
        </el-form-item>
        <el-form-item label="聯繫方式" prop="telphone">
          <el-input v-model="form.telphone" placeholder="請輸入聯繫方式" />
        </el-form-item>
        <el-form-item label="電子郵箱" prop="email">
          <el-input v-model="form.email" placeholder="請輸入電子郵箱" />
        </el-form-item>
        <el-form-item label="預約事項" prop="matter">
          <el-select v-model="form.matter" placeholder="請選擇預約事項">
            <el-option
              v-for="dict in dict.type.reservation_matter"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="預約時間">
          <el-date-picker
            clearable
            v-model="form.reservationTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="請選擇預約時間"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="內容描述">
          <editor v-model="form.content" :min-height="192" />
        </el-form-item>
      </el-form>

      <div style="text-align: center">
        <el-button type="primary" @click="submitForm">提 交</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </div>
  </div>
</template>

<script>
import {  addReservation } from "@/api/biz/reservation";
export default {
  name: "Reservationpersonal",
  dicts: ["reservation_matter"],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中數組
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 顯示搜索条件
      showSearch: true,
      // 总条數
      total: 0,
      // 客戶预约表格數据
      reservationList: [],
      // 弹出层標题
      title: "",
      // 是否顯示弹出层
      open: false,
      // 查询參數
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        customerId: null,
        customerCode: null,
        customerName: null,
        reservationType: null,
        inviter: null,
        matter: null,
        content: null,
        reservationTime: null,
        receiver: null,
        telphone: null,
        email: null,
        receiverName: null,
        completeTime: null,
        reservationStatus: null,
        billStatus: null,
        billId: null,
        billCode: null,
        orderByColumn: "update_time",
        isAsc: "desc",
      },
      // 表单參數
      form: {},
      // 表单校验
      rules: {
        email: [
          { required: true, message: "電子郵箱不能為空", trigger: "blur" },
        ],
      },
    };
  },
  created() {
  },
  methods: {
    /** 提交按钮 */
    submitForm() {
      console.log(this.form);
      this.$refs["form"].validate((valid) => {
        if (valid) {
          addReservation(this.form).then((response) => {
            this.$modal.msgSuccess("新增成功");
          });
        }
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        customerId: null,
        customerCode: null,
        customerName: null,
        reservationType: null,
        inviter: null,
        matter: null,
        content: null,
        reservationTime: null,
        receiver: null,
        telphone: null,
        email: null,
        receiverName: null,
        completeTime: null,
        reservationStatus: null,
        billStatus: null,
        billId: null,
        createTime: null,
        createBy: null,
        updateTime: null,
        billCode: null,
        updateBy: null,
      };
      this.resetForm("form");
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
  },
};
</script>
<style>
.container_p {
  width: 400px;
  height: auto;
  margin: 0 auto;
}
</style>